<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-4.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	  xmlns:th="http://www.thymeleaf.org">
	<head>
		<meta charset="utf-8" />

		<title>长沙县卫计委数据安全解决方案</title>

		<meta name="keywords" content="数据安全解决方案,数据安全网关" />

		<meta name="description" content="专业数据安全解决方案" />

		<meta name="viewport" content="width=device-width, initial-scale=1.0" />



		<!-- basic styles -->



		<link th:href="@{/bootstrap/css/bootstrap.min.css}" rel="stylesheet" />

		<link rel="stylesheet" th:href="@{/bootstrap/font-awesome/css/font-awesome.css}" />



		<!--[if IE 7]>

		<link rel="stylesheet" th:href="@{/css/font-awesome-ie7.min.css}"/>

		<![endif]-->

		<!-- gds styles -->



		<link rel="stylesheet" th:href="@{/css/gds.min.css}" />

		<link rel="stylesheet" th:href="@{/css/gds-rtl.min.css}" />



		<!--[if lte IE 8]>

		<link rel="stylesheet" th:href="@{/css/gds-ie.min.css}"/>

		<![endif]-->



		<!-- inline styles related to this page -->



		<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->



		<!--[if lt IE 9]>

		<script th:src="@{/js/html5shiv.js}"></script>

		<script th:src="@{/js/respond.min.js}"></script>

		<![endif]-->
	</head>



	<body class="">
	<div class="nav-header">
		<div class="navbar navbar-fixed-top">
			<div class="navbar-inner">
				<div class="navbar-inner-main">
					<img th:src="@{/images/logo.png}" height="39" width="90" style="margin-top:10px;margin-bottom:10px;padding-left: 30px;" class="pull-left"/>
					<span style="float: left;padding:10px 20px 10px;margin-top: 5px;text-shadow: 1px 0 1px rgba(0,0,0,0.25); margin-left: -20px; font-size: 20px; font-weight: 200; color: #ffffff;">GAFF数据安全解决方案 </span>
					<!-- /.nav-collapse -->
				</div>
			</div>
			<!-- /navbar-inner -->
		</div>
	</div>
	<div style="margin: 10vh 0 20px;"></div>

	<div class="main-container">

		<div class="main-content-fluid" style="margin-left: 5vh;margin-right: 5vh;">
			<div class="row">
				<div class="col-sm-10 col-sm-offset-1">
					<div class="login-container">
						<div class="position-relative">
							<div id="forgot-box" class="forgot-box widget-box no-border">

								<div class="widget-body">

									<div class="widget-main">

										<h4 class="header red lighter bigger">

											<i class="icon-key"></i>

											设置密码

										</h4>



										<div class="spgds-6"></div>

										<form id="reset_form" name="reset_form">
											<div class="form-group">
												<label for="c_OLD_PWD">原密码</label>
												<input type="password" id="c_OLD_PWD" name="c_OLD_PWD" class="form-control" placeholder="请输入密码" />
											</div>
											<div class="form-group">
												<label for="c_NEW_PWD">新密码</label>
												<input type="password" id="c_NEW_PWD" name="c_NEW_PWD" class="form-control" placeholder="请输入密码" />
											</div>
											<div class="form-group">
												<label for="c_RE_PWD">确认密码</label>
												<input type="password" id="c_RE_PWD" name="c_RE_PWD" class="form-control" placeholder="请输入确认密码" />
											</div>
										</form>

									</div><!-- /widget-main -->

									<div class="">

										<button id="btn-ok" class="btn btn-sm btn-primary pull-right">

											确定

											<i class="icon-ok"></i>

										</button>
										<button onclick="javascript:history.go(-1)" class="btn btn-sm btn-default">
											返回
											<i class="icon-arrow-left"></i>

										</button>

									</div>


								</div><!-- /widget-body -->

							</div><!-- /forgot-box -->
						</div><!-- /position-relative -->
					</div>
				</div><!-- /.col -->

			</div><!-- /.row -->

		</div>

	</div><!-- /.main-container -->

	<div style="margin: 10vh 0 20px;"></div>
	<div class="center" style="margin-bottom: 20px;">&copy;湖南格凡安信科技有限公司版权所有2017-2018</div>

	<!-- basic scripts 111-->
	<!--[if !IE]> -->
	<script th:src="@{/js/jquery/jquery-2.1.1.js}"></script>

	<!-- <![endif]-->

	<!--[if IE]>

	<script th:src="@{/js/jquery/jquery.min.js"></script>

	<![endif]-->

	<script th:src="@{/bootstrap/js/bootstrap.js}"/>
	<script th:src="@{/js/jquery/jquery.form.js}"></script>

	<script th:src="@{/js/fuelux/fuelux.wizard.min.js}"></script>
	<script th:src="@{/js/bootbox.min.js}"></script>

	<script th:src="@{/js/gds-elements.min.js}"></script>
	<script th:src="@{/js/gds.min.js}"></script>

	<script type="text/javascript" th:src="@{/bootstrap/bootstrap-validator/js/bootstrapValidator.js}"></script>
	<!--<script type="text/javascript">
        /*if("ontouchend" in document) document.write("<script src='/static/js/jquery/jquery.mobile.custom.min.js'>");*/
	</script>-->


	<script>
        $(function(){

            (function($){
                $.fn.serializeJson=function(){
                    var serializeObj={};
                    var array=this.serializeArray();
                    var str=this.serialize();
                    $(array).each(function(){
                        if(serializeObj[this.name]){
                            if($.isArray(serializeObj[this.name])){
                                serializeObj[this.name].push(this.value);
                            }else{
                                serializeObj[this.name]=[serializeObj[this.name],this.value];
                            }
                        }else{
                            serializeObj[this.name]=this.value;
                        }
                    });
                    return serializeObj;
                };
            })(jQuery);

        });
	</script>
	<script th:inline="javascript">
        var contextPath =[[${#httpServletRequest.getContextPath()}]];
	</script>
	<!-- form validator -->
	<script type="text/javascript">
        $(document).ready(function() {
            // <![CDATA[
            $('#reset_form').bootstrapValidator({
                message: 'This value is not valid',
                excluded: ':disabled',
                feedbackIcons: {
                    valid: 'glyphicon glyphicon-ok',
                    invalid: 'glyphicon glyphicon-remove',
                    validating: 'glyphicon glyphicon-refresh'
                },
                fields: {
                    c_OLD_PWD: {
                        validators: {
                            notEmpty: {
                                message: '原密码不能为空'
                            }
                        }
                    },
                    c_NEW_PWD: {
                        validators: {
                            notEmpty: {
                                message: '新密码不能为空'
                            },
							stringLength: {
								min: 10,
								max: 32,
								message: '密码为10-32位字符'
							},regexp: {
								regexp: /^(?=.*[a-zA-Z])(?=.*\d)(?=.*[~#\^$@$!%*?&\.])[A-Za-z\d~#$\^@$!%*?&\.]{7,}$/,
								message: '密码必须包含英文字母，数字及特殊字符（~!@#$%^&*.?）'
							},different: {
								field: 'c_USER_EMAIL',
								message: '新密码不能和旧密码相同'
							}
                        }
                    },
                    c_RE_PWD: {
                        validators: {
                            notEmpty: {
                                message: '确认密码不能为空'
                            },
							identical: {
                                field: 'c_NEW_PWD',
                                message: '与新密码不一致'
                            }
                        }
                    }
                }
            }).on('error.form.bv', function (e) {
                console.log('error');

                // Active the panel element containing the first invalid element
                var $form = $(e.target),
                    validator = $form.data('bootstrapValidator'),
                    $invalidField = validator.getInvalidFields().eq(0),
                    $collapse = $invalidField.parents('.collapse');

                $collapse.collapse('show');
            });

            $("#btn-ok").on("click" , function () {
                if ($("#reset_form").data('bootstrapValidator').validate().isValid()) {
                    $.post(contextPath + "/saveNewPassword",{c_OLD_PWD : $("#c_OLD_PWD").val(),c_NEW_PWD:$("#c_NEW_PWD").val()} , function (data) {
                        if (null != data && 0 == data.code) {
                            window.location.href = contextPath + "/logout";
                        } else if (500 == data.code) {
                            bootbox.alert({
                                buttons: {
                                    ok : {
                                        lable : '确定',
                                        "className": "btn-sm btn-error"
                                    }
                                },
                                message: data.msg
                            });
                        }
                    })
                }
            });
            //]]>
        });
	</script>

</body>

</html>

